package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xmy.cultivate.entity.AppointSchool;
import com.xmy.cultivate.entity.Staff;
import com.xmy.cultivate.mapper.AppointSchoolMapper;
import com.xmy.cultivate.mapper.RecordCourseMapper;
import com.xmy.cultivate.mapper.StaffMapper;
import com.xmy.cultivate.service.AuthorityServic;
import com.xmy.cultivate.service.IAppointSchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;


@Service
public class AuthorityImpl implements AuthorityServic {

    @Autowired
    StaffMapper staffMapper;

    @Autowired
    RecordCourseMapper recordCourseMapper;
    public Integer get(String teacherId){


        int laber = 1;  //设置标志位
        if(teacherId.equals("1568138350324350975")){
            laber = 3;
        }else{
            List<Long> adminIdList = recordCourseMapper.selectAdminId();
            List<Long> adminCIdList = recordCourseMapper.selectAdminCId();
            List<Long> adminZIdList = recordCourseMapper.selectAdminZId();
            Staff staff = staffMapper.selectByAdminId(Long.valueOf(teacherId));
            if(!Objects.equals(staff,null)){
                //标志位1为普通老师，标志位2为校长，标志位3为财务或者主管
                if(!Objects.equals(staff,null)){
                    for(Long id : adminIdList){
                        if (Objects.equals(staff.getAdminId(), id)) {
                            laber = 2;
                            break;
                        }
                    }
                    for(Long id : adminCIdList){
                        if (Objects.equals(staff.getAdminId(), id)) {
                            laber = 3;
                            break;
                        }
                    }
                    for(Long id : adminZIdList){
                        if (Objects.equals(staff.getAdminId(), id)) {
                            laber = 3;
                            break;
                        }
                    }
                }
            }
        }
        return laber;
    }
}
